home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / mkbrush.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  7.5 KB  |  246 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Make-Brush - a script for the script-fu program
  5. ; by Seth Burgess 1997 <sjburges@ou.edu>
  6. ;
  7. ; 18-Dec-2000 fixed to work with the new convention (not inverted) of
  8. ;             gbr saver (jtl@gimp.org)
  9. ;
  10. ; This program is free software; you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation; either version 2 of the License, or
  13. ; (at your option) any later version.
  14. ;
  15. ; This program is distributed in the hope that it will be useful,
  16. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ; GNU General Public License for more details.
  19. ;
  20. ; You should have received a copy of the GNU General Public License
  21. ; along with this program; if not, write to the Free Software
  22. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24.  
  25. (define (script-fu-make-brush-rectangular name width height spacing )
  26.   (let* ((img (car (gimp-image-new width height GRAY)))
  27.      (drawable (car (gimp-layer-new img
  28.                     width height GRAY-IMAGE
  29.                     "MakeBrush" 100 NORMAL-MODE)))
  30.  
  31.      (filename (string-append gimp-directory
  32.                   "/brushes/r"
  33.                   (number->string width)
  34.                   "x"
  35.                   (number->string height)
  36.                   ".gbr")))
  37.  
  38.     (gimp-context-push)
  39.  
  40.     (gimp-image-undo-disable img)
  41.     (gimp-image-add-layer img drawable 0)
  42.  
  43.     (gimp-context-set-background '(255 255 255))
  44.     (gimp-drawable-fill drawable BACKGROUND-FILL)
  45.  
  46.     (gimp-rect-select img 0 0 width height CHANNEL-OP-REPLACE FALSE 0)
  47.     
  48.     (gimp-context-set-background '(0 0 0))
  49.     (gimp-edit-fill drawable BACKGROUND-FILL)
  50.  
  51.     (file-gbr-save 1 img drawable filename "" spacing name)
  52.     (gimp-image-delete img)
  53.  
  54.     (gimp-context-pop)
  55.  
  56.     (gimp-brushes-refresh)
  57.     (gimp-context-set-brush name)))
  58.  
  59. (script-fu-register "script-fu-make-brush-rectangular"
  60.             _"_Rectangular..."
  61.             "Create size of brush"
  62.             "Seth Burgess <sjburges@ou.edu>"
  63.             "Seth Burgess"
  64.             "1997"
  65.             ""
  66.             SF-STRING     _"Name"    "Rectangle"
  67.             SF-ADJUSTMENT _"Width"   '(20 1 200 1 10 0 1)
  68.             SF-ADJUSTMENT _"Height"  '(20 1 200 1 10 0 1)
  69.             SF-ADJUSTMENT _"Spacing" '(25 1 100 1 10 1 0))
  70.  
  71. (script-fu-menu-register "script-fu-make-brush-rectangular"
  72.              _"<Toolbox>/Xtns/Script-Fu/Make Brush")
  73.  
  74.  
  75. (define (script-fu-make-brush-rectangular-feathered name width height
  76.                             feathering spacing)
  77.   (let* ((widthplus (+ width feathering))
  78.      (heightplus (+ height feathering))
  79.      (img (car (gimp-image-new widthplus heightplus GRAY)))
  80.      (drawable (car (gimp-layer-new img
  81.                     widthplus heightplus GRAY-IMAGE
  82.                     "MakeBrush" 100 NORMAL-MODE)))
  83.  
  84.      (filename (string-append gimp-directory
  85.                   "/brushes/r"
  86.                   (number->string width)
  87.                   "x"
  88.                   (number->string height)
  89.                   "f"
  90.                   (number->string feathering)
  91.                   ".gbr")))
  92.  
  93.     (gimp-context-push)
  94.  
  95.     (gimp-image-undo-disable img)
  96.     (gimp-image-add-layer img drawable 0)
  97.  
  98.     (gimp-context-set-background '(255 255 255))
  99.     (gimp-drawable-fill drawable BACKGROUND-FILL)
  100.  
  101.     (cond ((< 0 feathering)
  102.        (gimp-rect-select img
  103.                  (/ feathering 2) (/ feathering 2)
  104.                  width height CHANNEL-OP-REPLACE TRUE feathering))
  105.       ((>= 0 feathering)
  106.        (gimp-rect-select img 0 0 width height CHANNEL-OP-REPLACE FALSE 0)))
  107.  
  108.     (gimp-context-set-background '(0 0 0))
  109.     (gimp-edit-fill drawable BACKGROUND-FILL)
  110.  
  111.     (file-gbr-save 1 img drawable filename "" spacing name)
  112.     (gimp-image-delete img)
  113.  
  114.     (gimp-context-pop)
  115.  
  116.     (gimp-brushes-refresh)
  117.     (gimp-context-set-brush name)))
  118.  
  119. (script-fu-register "script-fu-make-brush-rectangular-feathered"
  120.             _"Re_ctangular, Feathered..."
  121.             "Create size of brush"
  122.             "Seth Burgess <sjburges@ou.edu>"
  123.             "Seth Burgess"
  124.             "1997"
  125.             ""
  126.             SF-STRING     _"Name"       "Rectangle"
  127.             SF-ADJUSTMENT _"Width"      '(20 1 200 1 10 0 1)
  128.             SF-ADJUSTMENT _"Height"     '(20 1 200 1 10 0 1)
  129.             SF-ADJUSTMENT _"Feathering" '(4 1 100 1 10 0 1)
  130.             SF-ADJUSTMENT _"Spacing"    '(25 1 100 1 10 1 0))
  131.  
  132. (script-fu-menu-register "script-fu-make-brush-rectangular-feathered"
  133.              _"<Toolbox>/Xtns/Script-Fu/Make Brush")
  134.  
  135.  
  136. (define (script-fu-make-brush-elliptical name width height spacing)
  137.   (let* ((img (car (gimp-image-new width height GRAY)))
  138.      (drawable (car (gimp-layer-new img
  139.                     width height GRAY-IMAGE
  140.                     "MakeBrush" 100 NORMAL-MODE)))
  141.  
  142.      (filename (string-append gimp-directory
  143.                   "/brushes/e"
  144.                   (number->string width)
  145.                   "x"
  146.                   (number->string height)
  147.                   ".gbr")))
  148.  
  149.     (gimp-context-push)
  150.  
  151.     (gimp-image-undo-disable img)
  152.     (gimp-image-add-layer img drawable 0)
  153.  
  154.     (gimp-context-set-background '(255 255 255))
  155.     (gimp-drawable-fill drawable BACKGROUND-FILL)
  156.     (gimp-context-set-background '(0 0 0))
  157.     (gimp-ellipse-select img 0 0 width height CHANNEL-OP-REPLACE TRUE FALSE 0)
  158.     
  159.     (gimp-edit-fill drawable BACKGROUND-FILL)
  160.  
  161.     (file-gbr-save 1 img drawable filename "" spacing name)
  162.     (gimp-image-delete img)
  163.  
  164.     (gimp-context-pop)
  165.  
  166.     (gimp-brushes-refresh)
  167.     (gimp-context-set-brush name)))
  168.  
  169. (script-fu-register "script-fu-make-brush-elliptical"
  170.             _"_Elliptical..."
  171.             "Create size of brush"
  172.             "Seth Burgess <sjburges@ou.edu>"
  173.             "Seth Burgess"
  174.             "1997"
  175.             ""
  176.             SF-STRING     _"Name"    "Ellipse"
  177.             SF-ADJUSTMENT _"Width"   '(20 1 200 1 10 0 1)
  178.             SF-ADJUSTMENT _"Height"  '(20 1 200 1 10 0 1)
  179.             SF-ADJUSTMENT _"Spacing" '(25 1 100 1 10 1 0))
  180.  
  181. (script-fu-menu-register "script-fu-make-brush-elliptical"
  182.              _"<Toolbox>/Xtns/Script-Fu/Make Brush")
  183.  
  184.  
  185. (define (script-fu-make-brush-elliptical-feathered name width height
  186.                            feathering spacing)
  187.   (let* ((widthplus (+ feathering width)) ; add 3 for blurring
  188.      (heightplus (+ feathering height))
  189.      (img (car (gimp-image-new widthplus heightplus GRAY)))
  190.      (drawable (car (gimp-layer-new img
  191.                     widthplus heightplus GRAY-IMAGE
  192.                     "MakeBrush" 100 NORMAL-MODE)))
  193.  
  194.      (filename (string-append gimp-directory
  195.                   "/brushes/e"
  196.                   (number->string width)
  197.                   "x"
  198.                   (number->string height)
  199.                   "f"
  200.                   (number->string feathering)
  201.                   ".gbr")))
  202.  
  203.     (gimp-context-push)
  204.  
  205.     (gimp-image-undo-disable img)
  206.     (gimp-image-add-layer img drawable 0)
  207.  
  208.     (gimp-context-set-background '(255 255 255))
  209.     (gimp-drawable-fill drawable BACKGROUND-FILL)
  210.  
  211.     (cond ((> feathering 0)   ; keep from taking out gimp with stupid entry. 
  212.         (gimp-ellipse-select img
  213.                  (/ feathering 2) (/ feathering 2)
  214.                  width height CHANNEL-OP-REPLACE
  215.                  TRUE TRUE feathering))
  216.           ((<= feathering 0)
  217.         (gimp-ellipse-select img 0 0 width height
  218.                  CHANNEL-OP-REPLACE TRUE FALSE 0)))
  219.  
  220.     (gimp-context-set-background '(0 0 0))
  221.     (gimp-edit-fill drawable BACKGROUND-FILL)
  222.  
  223.     (file-gbr-save 1 img drawable filename "" spacing name)
  224.     (gimp-image-delete img)
  225.  
  226.     (gimp-context-pop)
  227.     
  228.     (gimp-brushes-refresh)
  229.     (gimp-context-set-brush name)))
  230.  
  231. (script-fu-register "script-fu-make-brush-elliptical-feathered"
  232.             _"Elli_ptical, Feathered..."
  233.             "Makes a feathered elliptical brush of specified size"
  234.             "Seth Burgess <sjburges@ou.edu>"
  235.             "Seth Burgess"
  236.             "1997"
  237.             ""
  238.             SF-STRING     _"Name"       "Ellipse"
  239.             SF-ADJUSTMENT _"Width"      '(20 1 200 1 10 0 1)
  240.             SF-ADJUSTMENT _"Height"     '(20 1 200 1 10 0 1)
  241.             SF-ADJUSTMENT _"Feathering" '(4 1 100 1 10 0 1)
  242.             SF-ADJUSTMENT _"Spacing"    '(25 1 100 1 10 1 0))
  243.  
  244. (script-fu-menu-register "script-fu-make-brush-elliptical-feathered"
  245.              _"<Toolbox>/Xtns/Script-Fu/Make Brush")
  246.